package com.xintonghua.hongyi.ui.fragment;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.xintonghua.base.ui.BaseFragment;
import com.xintonghua.base.ui.MySubscriber;
import com.xintonghua.base.utils.RefreshUtils;
import com.xintonghua.hongyi.R;
import com.xintonghua.hongyi.adapter.CollegeAdapter;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;

/**
 * 作者：wanxianyi
 * 时间：2018/1/9.
 * 包名：com.xintonghua.hongyi.ui.fragment
 */

public class CultureFragment extends BaseFragment implements XRecyclerView.LoadingListener {
    @BindView(R.id.tab_price)
    TabLayout tabPrice;
    @BindView(R.id.lv_price)
    XRecyclerView lvPrice;
    Unbinder unbinder;
    private String[] title = new String[]{"首页", "健康", "时尚", "新闻", "美发", "保养"};
    CollegeAdapter adapter;

    @Override
    public int getLayout() {
        return R.layout.fragment_culture;
    }

    @Override
    public void initUI(View view) {
        unbinder = ButterKnife.bind(this, view);
        for (String s : title) {
            tabPrice.addTab(tabPrice.newTab().setText(s));
        }
        RefreshUtils.initList(getActivity(), lvPrice);
        View head = LayoutInflater.from(getContext()).inflate(R.layout.layout_price, lvPrice, false);
        lvPrice.addHeaderView(head);
        adapter = new CollegeAdapter(getActivity(), new ArrayList<String>());
        lvPrice.setAdapter(adapter);
        lvPrice.setLoadingListener(this);
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @Override
    public void onRefresh() {
        RefreshUtils.onRefresh(adapter,lvPrice);
    }

    @Override
    public void onLoadMore() {
        RefreshUtils.onRefresh(adapter,lvPrice);
    }
}
